package route

import (
	"cloud-disk/handler"
	"cloud-disk/middleware"
	"github.com/gin-gonic/gin"
)

func InitRouter() *gin.Engine {
	router := gin.Default()

	router.POST("/user/login", handler.UserLoginHandler)
	router.POST("/user/register", handler.UserRegisterHandler)
	router.POST("/user/captcha", handler.UserCaptchaHandler)

	router.Use(middleware.Auth())

	router.GET("/user/info", handler.UserInfoHandler)

	router.POST("/dir/upload", handler.DirUploadHandler)
	router.POST("/file/upload/prepare", handler.PrepareUploadHandler)
	router.POST("/file/upload", handler.FileUploadHandler)
	router.GET("/file/list", handler.UserFileListHandler)
	router.GET("/file/info/:id", handler.FileInfoHandler)
	router.GET("/dir/info/:id", handler.DirInfoHandler)
	router.DELETE("/file/delete", handler.UserFileDeleteHandler)
	router.PUT("/file/move", handler.UserFileMoveHandler)
	router.PUT("/file/rename", handler.UserFileRenameHandler)

	router.GET("/mpupload/init", handler.InitMultipartUploadHandler)
	router.POST("/mpupload/chunk", handler.MultipartUploadHandler)
	router.POST("/mpupload/merge", handler.MergeMultiPartHandler)

	router.POST("/share", handler.CreateShareHandler)
	router.GET("/share", handler.AccessShareFileHandler)
	router.POST("/share/save", handler.SaveShareHandler)

	router.GET("/download/:repositoryIdentity", handler.FileDownloadHandler)

	return router
}
